<template>
  <div class="todo-header">
        <input type="text" placeholder="请输入你的任务名称，按回车键确认" @keyup.enter="addTodoHandle" />
      </div>
</template>

<script>
export default {
  props:['addTodo'],
  methods: {
    addTodoHandle(e){
      let value = e.target.value.trim();
      if(value === '') return alert('请输入内容');
      let todoObj = {
        id:Date.now(),
        title:value,
        done:false
      };
      this.addTodo(todoObj);
      e.target.value = '';
    }
  }
}
</script>

<style>

</style>